#include "resourcemanager.h"

ResourceManager* ResourceManager::instance = NULL;

ResourceManager::ResourceManager(void) {
	this->isPlayerSet = false;
}

ResourceManager::~ResourceManager(void) {
	objectMap.clear();
	itemMap.clear();
}

ResourceManager* ResourceManager::getInstance() {
	if (instance == NULL)
		instance = new ResourceManager();
	return instance;
}

void ResourceManager::destroyInstance() {
	delete (instance);
}

void ResourceManager::addGameItem(char key, Item* item) {
	itemMap[key] = item;
	graphicsMap[key] = item->getImage();
}

void ResourceManager::addGameObject(char key, Object* object) {
	objectMap[key] = object;
	graphicsMap[key] = object->getObjectImage();
}

Item* ResourceManager::getGameItem(char key) {
	return itemMap[key];
}

Object* ResourceManager::getGameObject(char key) {
	return objectMap[key];
}

void ResourceManager::setPlayer(Player* player) {
	if (!isPlayerSet) {
		this->player = player;
	}
}

Player* ResourceManager::getPlayer() {
	return player;
}

void ResourceManager::setLevel(Level* level) {
	this->level = level;
}

Level* ResourceManager::getLevel() {
	return level;
}

void ResourceManager::addGameSprite(char key, CL_Sprite* sprite) {
	this->graphicsMap[key] = sprite;
}

CL_Sprite* ResourceManager::getGameSprite(char key) {
	return graphicsMap[key];
}

void ResourceManager::setEnemy(Enemy* enemy) {
	this->enemy = enemy;
}

Enemy* ResourceManager::getEnemy() {
	return enemy;
}

